﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace MarsWorkUtility
{
    class TreeView_OP
    {
        //向Treeview添加根节点。
        public TreeNode FillRootNode(TreeView Host_TreeView,string RootNode)
        {
            try
            {
                TreeNode tn = new TreeNode(RootNode);
                Host_TreeView.Nodes.Add(tn);
                return tn;
            }
            catch(Exception e)
            {
                throw e;
            }
        }
        //向Treeview添加子节点。
        public TreeNode FillLeafNode(string HostFile,TreeNode tn)
        {
            try
            {        
                StreamReader sr = new StreamReader(HostFile);
                
                while (sr.Peek() >= 0)
                {
                    TreeNode tn1 = new TreeNode(sr.ReadLine());
                    tn.Nodes.Add(tn1);
                }
                sr.Close();
                return tn;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
    }
}
